package com.oocl.crm;

import org.w3c.dom.Node;



//该链表除去头节点，其余实际节点位置下标从1开始
public class DoubleLinkList<T>{

	public class Node<T>{
		public Node<T> prev=null;
		public Node<T> next=null;
		private T data ;
		public Node(T t){
			this.data=t;
		}
		public Node(){
		}
		public Node<T> getPrev() {
			return prev;
		}
		public void setPrev(Node<T> prev) {
			this.prev = prev;
		}
		public Node<T> getNext() {
			return next;
		}
		public void setNext(Node<T> next) {
			this.next = next;
		}
		public T getData() {
			return data;
		}
		public void setData(T data) {
			this.data = data;
		}	
	}
	private Node<T> head = new Node<T>(null);
	private Node<T> pointer = head;
	private int size=0;
	
	public Node<T> getHead() {
		return head;
	}
	public int getSize()
	{
		return size;
	}
	public void addSize()
	{	
		size++;
	}
	public void reduceSize()
	{	
		size--;
	}
	public void addNode(T t) {
		Node<T> n = new Node<T>(t);
		if(head==pointer) {
			head.setNext(n);
			n.setPrev(head);
			pointer=n;
		}
		else{
			n.setPrev(pointer);
			pointer.setNext(n);
			
		}
		pointer=n;
		addSize();
	}
}
